#include "matrix.h"
#include <iostream>
#include <fstream>
using namespace std;

/*********Ma Tran*************/
void MaTran::init(int r, int c)
{
	//cout<<r<<" "<<c<<endl;//test
	matrix_size.x=r;
	matrix_size.y=c;
	matrix.resize(r);
	for(int i=0;i<r;i++)
		matrix[i].resize(c);
}

istream& operator >> (istream& inDevice,MaTran &a)
{
	int row,collumn;
	int i,j;//dem
	inDevice>>row;//Lay kich thuoc
	inDevice>>collumn;
	//cout<<row<<" "<<collumn<<endl;//test
	a.init(row,collumn);
	string temp;
	for(i=0;i<row;i++)
		for(j=0;j<collumn;j++)
		{
			a.matrix[i][j]="";
			if(inDevice)
			{
				inDevice>>temp;
				a.matrix[i][j]=temp;
			}
		}
	return inDevice;
}

ostream& operator << (ostream& outDevice,MaTran &a)
{
	int i,j;
	int n=a.matrix.size();
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			outDevice<<a.matrix[i][j]<<"\t";			
		outDevice<<endl;
	}
	return outDevice;
}

Pair_xy MaTran::size()
{
	//cout<<matrix_size.x<<" "<<matrix_size.y<<endl;//test
	return matrix_size;
}

string& MaTran::operator ()(int i, int j)
{
	
	return matrix[i][j];
}
